Action Brings MacWrite Pro to the front, if it is currently active
Returns True if MacWrite is running and is now frontmost, false if not
Examples MacWrite.bringToFront()
» True
See Also MacWrite.launch()
MacWrite.isRunning()
Verb MacWrite.changeAll
Syntax MacWrite.changeAll(fromString, toString)
Parameters fromString is the string to be replaced
toString is the string (may be empty) which replaces the fromString occurrences
Action Starts searching from the beginning of the document for fromString. For each and every occurrence it deletes that string and replaces the toString contents.
Notes Searching by whole word and the case sensitivity are specifed using the verbs MacWrite.setWholeword and MacWrite.setCaseSensitive.
See Also MacWrite.setWholeword
MacWrite.setCaseSensitive
MacWrite.findNext
MacWrite.find
Verb MacWrite.chooseDocument
Syntax MacWrite.chooseDocument(documentID)
Parameters documentID is a number which refers to a specific MacWrite Pro document
Action brings the specified document to the front, and makes it the active document
Returns True if the document exists. Invokes an error an returns false if the document doesn’t exist.
Examples MacWrite.chooseDocument(docID)
» True
See Also MacWrite.getDocumentID
MacWrite.listDocumentIDs
Verb MacWrite.closeDocument
Syntax MacWrite.closeDocument()
Parameters None
Action Closes the frontmost MacWrite document
Returns True if document was closed, false if the user canceled the close.
Examples MacWrite.closeDocument()
» True
See Also MacWrite.closeDocWithSave
Verb MacWrite.closeDocWithSave
Syntax MacWrite.closeDocWithSave(saveOption)
Parameters saveOption is an enumerator specifying that the document should be saved (MacWrite.kYes), should not be saved (kNo) or the user should be asked (kAsk)
Action Closes the frontmost document, bringing the application forward if necessary, with the save option as supplied.
Returns False - means the user canceled the save.
True - means the document was closed successfully
Examples MacWrite.closeDocWithSave(MacWrite.kNo)
» true
See Also MacWrite.closeDocument
Verb MacWrite.closeMergeDataFile
Syntax MacWrite.closeMergeDataFile()
Parameters None
Action Closes any open merge data file, no error if there isn't one open already.
Returns True
Examples MacWrite.closeMergeDataFile()
» True
See Also MacWrite.doMerge
MacWrite.openmergedatafile
MacWrite.setMergeRange
Verb MacWrite.copy
Syntax MacWrite.copy()
Parameters None
Action Instructs MacWrite to copy the selected item(s) and put them on the clipbard
Returns True
Examples MacWrite.copy()
» True
See Also MacWrite.cut
MacWrite.paste
Verb MacWrite.countDocuments
Syntax MacWrite.countDocuments()
Parameters None
Action Requests the number of MacWrite Pro documents currently open
Returns A number containing the number of documents open and visible
Examples MacWrite.countDocuments()
» 3
Notes This does not count the clipboard window, nor the floaters since they are not accessible through Apple Events
Verb MacWrite.cut
Syntax MacWrite.cut()
Parameters None
Action Instructs MacWrite to cut the selected item(s) and put them on the clipbard
Returns True
Examples MacWrite.cut()
» True
See Also MacWrite.cut
MacWrite.paste
Verb MacWrite.doMenuItem
Syntax MacWrite.doMenuItem(menuItemNumber)
Parameters menuItemNumber is an enumerated item, found in the table "MacWrite.menuIDs"
The value represents the menu item you wish to select
Action If the item you're choosing is enabled, the item is selected
Returns True if the menu item was enabled, false if not.
Parameters isCharacter is a boolean flag which specifies MacWrite should search for the next character or paragraph style sheet
Action Using the user defined list passed by the verb MacWrite.setStyleSheetSearchList, this verb causes MacWrite to search from the current caret position.
When a style sheet on the defined list is located, the selection is set to the text defiend by the sheet, and the ID of the located sheet is returned.
Returns A number which is the ID of the style sheet located. -2 indicates no occurrence was found.
Examples MacWrite.findNextstylesheetinlist(True)
» 3
Notes This verb, unlike Find, does not wrap at the end of the document
See Also MacWrite.setStyleSheetSearchList
Verb MacWrite.getChars
Syntax MacWrite.getChars()
Parameters None
Action Returns the currently selected text
Returns String containing current selection
Examples MacWrite.getChars()
» This text was selected when I issued the getChars command !
See Also MacWrite.putChars
MacWrite.setSelection
MacWrite.getSelection
MacWrite.textLength
Verb MacWrite.getDocumentID
Syntax MacWrite.getDocumentID()
Parameters None
Action Requests the document ID of the front most document
Returns A number representing the current document. If no documents are open, invokes an error ("No such document")
Examples MacWrite.getDocumentID()
» 8
See Also MacWrite.chooseDocument
MacWrite.listDocumentIDs
Verb MacWrite.getDocumentName
Syntax MacWrite.getDocumentName()
Parameters None
Action Requests the name of the front most document
Returns A string containing the name of the front most document. This is an empty string if no documents are open
Examples MacWrite.getDocumentName()
» "The World According To Garp"
See Also MacWrite.getDocumentID
MacWrite.countDocuments
Verb MacWrite.getPageNumber
Syntax MacWrite.getPageNumber()
Parameters None
Action Returns the page number containing the user selection. If the selection spans pages, it returns the first page.
Returns A string containing the page number.
Examples MacWrite.getPageNumber()
» "3"
Notes -2 indicates that no document was open, or there was no text selected.
-1 indicates that the selection is in an endnote page
Notes The name of the style sheet is not case sensitive
The number is not persistent - if the user modifies the style sheet list by adding or deleting styles, this number can change
See Also MacWrite.listStyleSheets
Verb MacWrite.getVersion
Syntax MacWrite.getVersion()
Parameters None
Action Returns the version of script handling in the running version of MacWrite Pro
Returns A long ineteger with the major version in the high word, and the minor version information in the lower word. For example, if this was version 1.02, this would return 65538.
Examples MacWrite.getVersion()
» 65537 (1.01)
MacWrite.getVersion()
» 13172737 (Demo of 1.01, 201.01)
Notes MacWrite Pro 1.0, which shipped with some very limited Apple Event support returns 1 (0.1). We are currently shipping 1.01
A demo version of MacWrite Pro will return a major version of 200 higher than it’s “real” version.
Verb MacWrite.insertFile
Syntax MacWrite.insertFile(path)
Parameters path is the path to the file you wish to insert into the current MacWrite document
Action Read the contents of a particular file and place them at the current insertion point, replacing the current seletion if any.
Returns True if the document was inserted, false if not.
Examples MacWrite.insertFile(":Examples:insert this file")
» true
Verb MacWrite.isRunning
Syntax MacWrite.isRunning()
Parameters None
Action Determines if MacWrite Pro is running
Returns True if MacWrite Pro is running, false if not
Examples MacWrite.isRunning()
» True
Verb MacWrite.launch
Syntax MacWrite.launch()
Parameters None
Action If MacWrite is not already running, this verb launches MacWrite
Returns True if MacWrite is running, false if it couldn’t be found
Examples MacWrite.launch()
» True
Verb MacWrite.listDocumentIDs
Syntax MacWrite.listDocumentIDs()
Parameters None
Action A request for a list of the ID of each currently open document
Returns A list of document IDs
Examples MacWrite.listDocumentIDs()
» 1 3 as a list…
Notes Document IDs are unique and start from 1 each time you run MacWrite Pro.
See Also MacWrite.getDocumentID
MacWrite.chooseDocument
Verb MacWrite.listStyleSheets
Syntax MacWrite.listStyleSheets(isCharacter)
Parameters isCharacter is a boolean which should be set to tru for character styles or false for paragraphs
Action Compiles a list of all the specified custom styles and makes a list of them
Returns A list of strings containing the names of the specified custom styles
Examples MacWrite.listStyleSheets(true)
» "Header" "Footer" "Red 14 point" as a list
See Also MacWrite.getStylesheetID
Verb MacWrite.newDocument
Syntax MacWrite.newDocument()
Parameters None
Action Creates a new document.
Returns True if a document was created and opened, false if not.
Examples MacWrite.newDocument()
» True
Verb MacWrite.openDocument
Syntax MacWrite.openDocument(path)
Parameters path is the path to the file you wish to open in MacWrite
Action Asks MacWrite Pro to open the specified document.
Returns True if the document was found and opened. An appropriate error is returned if the document cannot be opened.
Examples MacWrite.openDocument("My Hard Disk:Samples:Example document")
» True
Verb MacWrite.openMergeDataFile
Syntax MacWrite.openmergedatafile(path)
Parameters path is the path to the mail merge data file you wish to open
Action Opens the specific data file, and opens the mail merge palette if not already open
Returns True if file opened, false if an error occurred
Parameters flag is a boolean specifying you wish to search for whole words (true) or not (false)
Action Setting this flag true causes all the find verbs to search using whole words
Returns Previous setting of this flag.
Examples MacWrite.setWholeword(false)
» True
See Also MacWrite.find
MacWrite.setCaseSensitive
MacWrite.findNext
MacWrite.changeAll
Verb MacWrite.textLength
Syntax MacWrite.textLength()
Parameters None
Action Counts the characters contained within the main body of the frontmost document
Returns A number indicating the number of characters in the main body.
Examples MacWrite.textLength()
» 16388
Notes MacWrite Pro has special characters which are counted as 1 character, but may be returned through getChars as either no characters or more than one. So the count may not be the exact number of characters you will get back using getChars.
For example, the date and time characters only occupy one character, yet will return many. Inline frames occupy one character space, and will be returned by getChars as a space.